package hxy.bytecode.algorithm;

import java.util.Arrays;

public class QuickSort2 {

	static void Sort(int a[], int left, int right) {
		int left1 = left;
		int right1 = right;
		int base = left;
		while (left < right) {
			if (a[left] > a[base]) {
				int temp = a[left];
				a[left] = a[base];
				a[base] = temp;
			} else if (a[right] < a[base]) {
				int temp = a[right];
				a[right] = a[base];
				a[base] = temp;
			}
			left++;
			right--;
		}
		Sort(a, left1, base - 1);
		Sort(a, base + 1, right1);
	}

	public static void main(String[] args) {
		int[] a = { 4, 1, 8, 3, 2, 5, 0, 9, 6, 7 };
		QuickSort2.Sort(a, 0, a.length - 1);
		System.out.println(Arrays.toString(a));

	}

}
